<?php
namespace app\admin\model;

use think\facade\Db;

class Cate{
    public static function CateList($pid)
    {
        $list = Db::table('ecm_category')
            ->where('parentid','=',$pid)
            ->order('sort')
            ->select()
            ->toArray();
        $arr = Db::table('ecm_category')
            ->field(true)
            ->select()
            ->toArray();
        foreach ($list as &$v){
            foreach ($arr as $vv){
                if($v['id'] == $vv['parentid']){
                    $v['name'] = "<a href='?pid={$v['id']}'>{$v['name']}</a>";
                    break;
                }
            }
        }
        return $list;
    }
}
